package com.jt.common.util;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduledExecutorServiceTests {
    public static void main(String[] args) {
        ScheduledExecutorService ses =
                Executors.newScheduledThreadPool(3);

        Runnable task = new Runnable() {
            @Override
            public void run() {
                String tName = Thread.currentThread().getName();
                System.out.println(tName+"->"+System.currentTimeMillis());
            }
        };

        ses.scheduleAtFixedRate(task, //
                            1,//初始延迟
                            1,//每隔1秒启动一次
                    TimeUnit.SECONDS//时间单位
                );
    }
}
